<?php

namespace app\index\controller;

use think\Db;
use think\facade\Request;
use think\facade\View;
use think\facade\Session;
use app\index\model\WxUser;

class Index extends Common
{

    protected $tdkApi = 'https://api.bestyoujia.com/api/index/getTdkInfoByCode';

    public function index()
    {
        $reqData['code'] = 'zmyj-home';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        View::share('showLink', 1);
        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function esthetics()
    {
        $reqData['code'] = 'zmyj-esthetics';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function reform()
    {
        $reqData['code'] = 'zmyj-reform';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function building()
    {
        $reqData['code'] = 'zmyj-building';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];
        $this->assign('tdk', $tdk);

        $result = curl('https://ujia-img.oss-cn-shenzhen.aliyuncs.com/beauthome/building/demo.json');

        $this->assign('list', json_decode($result, true));

        return $this->fetch();
    }

    public function curtain()
    {
        $reqData['code'] = 'zmyj-curtain';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function furniture()
    {
        $reqData['code'] = 'zmyj-furniture';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function customization()
    {
        $reqData['code'] = 'zmyj-customization';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    public function cases()
    {
        $reqData['code'] = 'zmyj-cases';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);

        $styleList = Db::name('cases_style')->where('enabled', 1)->select();

        $housing = ['2室', '3室', '4室', '别墅', '其他户型'];

        $type = array((array('id' => 1, 'name' => '实景案例'))
        , (array('id' => 2, 'name' => '效果图案例'))
        , (array('id' => 3, 'name' => 'VR案例')));

        $area = array((array('id' => 1, 'name' => '100m²以下'))
        , (array('id' => 2, 'name' => '100-140m²'))
        , (array('id' => 3, 'name' => '140-200m²'))
        , (array('id' => 4, 'name' => '200-300㎡'))
        , (array('id' => 5, 'name' => '300m²以上')));

        $filterData = Request::only(['type', 'building', 'style', 'housing', 'area'], 'get');
        $filter = [];

        $building = '';
        // 根据楼盘名称模糊查询
        if (isset($filterData['building'])) {
            $building = $filterData['building'];
        }

        // 根据案例类型查询
        if (isset($filterData['type']) && !empty($filterData['type'])) {
            $filter[] = array('case_type', '=', $filterData['type']);
        }

        // 根据风格查询
        if (isset($filterData['style']) && !empty($filterData['style'])) {
            $filter[] = array('style', 'like', '%' . $filterData['style'] . '%');
        }

        // 根据户型查询
        if (isset($filterData['housing']) && !empty($filterData['housing'])) {
            $filter[] = array('housing', 'like', '%' . $filterData['housing'] . '%');
        }

        // 根据面积查询
        if (isset($filterData['area']) && !empty($filterData['area'])) {
            switch ($filterData['area']) {
                case 1:
                    $filter[] = array('area', '<', '100');
                    break;
                case 2:
                    $filter[] = array('area', 'between', ['100', '140']);
                    break;
                case 3:
                    $filter[] = array('area', 'between', ['140', '200']);
                    break;
                case 4:
                    $filter[] = array('area', 'between', ['200', '300']);
                    break;
                case 5:
                    $filter[] = array('area', '>', '300');
                    break;
            }
        }

        $module = 'ZMYJ01';
        $list = Db::name('cases')->where('module', 'like', '%' . $module . '%')->where($filter)->where('enabled', 1)->where('is_trash', 0)->order('id desc')->paginate(12);

        $this->assign('type', $type);
        $this->assign('styleList', $styleList);
        $this->assign('housing', $housing);
        $this->assign('area', $area);
        $this->assign('list', $list);

//        $db = Db::connect('mysql://root:bg*YDHU8ZWRPNZ@47.108.77.65:3306/management#utf8');
//
//        $moduleCode = 'UJGC02';
//
//        $cases = $db->name('u_cases')->where('case_type', 5)->where('module','like','%' . $moduleCode . '%')->where('enabled', 1)->where('is_trash', 0)->order('sort desc, id desc')->select();
//
//        $this->assign('cases', $cases);
//
        $result = curl('https://ujia-img.oss-cn-shenzhen.aliyuncs.com/cases/demo.json');

        $this->assign('list', $list);
//
        return $this->fetch();
    }

    /**
     * 案例详情
     * @return mixed
     * @throws \think\Exception
     */
    public function case()
    {
        $id = request()->route('id');

        $module = 'ZMYJ01';

        // 更新阅读量
        Db::name('cases')->where('id', $id)->inc('view_count')->update();

        $case = Db::view('cases', 'id,cover,style AS case_style,housing,area,article_id,building,create_time,view_count')
            ->view('article', 'title,author,content,tag,summary', 'article.id=cases.article_id')
            ->view('designer', 'name,appointment_count,nick_name,avatar,type,intro,style', 'designer.id=cases.designer1_id OR designer.id=cases.designer2_id OR designer.id=cases.designer3_id OR designer.id=cases.designer4_id')
            ->where('cases.id', $id)
            ->whereLike('cases.module', '%' . $module . '%')
            ->find();

        // 案例浏览量统计
        Db::name('cases')->where('id', $id)->setInc('view_count');

        // 文章阅读量统计
        Db::name('article')->where('id', $case['article_id'])->setInc('view_count');

        $relevant = Db::name('cases')->where('id', '<>', $id)->whereLike('module', '%' . $module . '%')->where('enabled', 1)->where('is_trash', 0)->order('view_count desc,sort desc,create_time desc')->limit(3)->select();

//        $db = Db::connect('mysql://root:bg*YDHU8ZWRPNZ@47.108.77.65:3306/management#utf8');
//
//        // 阅读量统计
//        $db->name('u_cases')->where('id', $id)->setInc('view_count');
//
//        $case = $db->name('u_cases')
//        ->alias('a')
//        ->join('u_article b', 'b.id = a.article_id')
////        ->join('u_designer c', 'c.id = a.designer1_id OR c.id = a.designer2_id OR c.id = a.designer3_id OR c.id = a.designer4_id')
////        ->field('a.building,a.view_count,a.style,a.housing,a.area,a.create_time,b.id as article_id,b.author,b.content,c.nick_name as designer,c.avatar,c.style as designer_style,c.appointment_count')
//        ->where('a.id', $id)
//        ->find();
//
//        $db->name('u_article')->where('id', $case['article_id'])->setInc('view_count');
//
        if (!$case) {
            abort(404);
        }

        $this->assign('case', $case);
        $this->assign('relevant', $relevant);

        if (!$case) {
            $tdk['title'] = '案例详情-致美优家';
        } else {
            $tdk['title'] = $case['title'];
        }

        $tdk['description'] = $case['summary'];
        $tdk['keywords'] = $case['tag'];

        $this->assign('tdk', $tdk);

        return $this->fetch();
    }

    public function about()
    {
        $reqData['code'] = 'zmyj-about';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /*
     * 公司动态
     */
    public function news()
    {
        $reqData['code'] = 'zmyj-news';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $list = Db::name('article')->where('channel', 'ZMYJ')->where('category', 2)->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc, sort desc, id desc')->paginate(15);

        $this->assign('list', $list);

        $this->assign('tdk', $tdk);

        return $this->fetch();
    }

    /**
     * 文章详情页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function article()
    {
        $id = request()->route('id');

        $article = Db::name('article')->where('channel', 'ZMYJ')->where('category', 2)->where('id', $id)->whereTime('publish_time', '<=',  date('Y-m-d H:i:s', time()))->find();

        // 阅读量统计
        Db::name('article')->where('id', $id)->setInc('view_count');

        // 上一篇
        $prev = Db::name('article')->where('channel', 'ZMYJ')->where('category', 2)->where('id', '<', $id)->where('category', '<>', 14)->where('enabled', 1)->where('is_trash', 0)->order('id desc')->limit('1')->find();
        // 下一篇
        $next = Db::name('article')->where('channel', 'ZMYJ')->where('category', 2)->where('id', '>', $id)->where('category', '<>', 14)->where('enabled', 1)->where('is_trash', 0)->order('id asc')->limit('1')->find();

        $category = Db::name('article_category')->where('id', $article['category'])->find();

        $newest = Db::name('article')->where('channel', 'ZMYJ')->where('category', 2)->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc')->limit(5)->select();

        $relevant = Db::name('article')->where('channel', 'ZMYJ')->where('category', $category['id'])->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc')->limit(5)->select();


        $this->assign('category', $category);
        $this->assign('article', $article);
        $this->assign('newest', $newest);
        $this->assign('relevant', $relevant);
        $this->assign('prev', $prev);
        $this->assign('next', $next);

        if (!$article) {
            abort(404);
        }


        $tdk['title'] = $article['title'];
        $tdk['description'] = $article['summary'];
        $tdk['keywords'] = $article['tag'];

        $this->assign('tdk', $tdk);

        return $this->fetch();
    }

    public function baike()
    {
        $categoryCode = request()->route('category');


        if ($categoryCode === 'rzdp') {
            $category = 21;
        }
        if ($categoryCode === 'qwdz') {
            $category = 22;
        }
        if ($categoryCode === 'jzgz') {
            $category = 23;
        }
        if ($categoryCode === 'rzzs') {
            $category = 24;
        }

        if (empty($categoryCode)) {
            $list = Db::name('article')->where('channel', 'ZMYJ')->whereIn('category', '21, 22, 23, 24')->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc, sort desc, id desc')->paginate(10);

            $reqData['code'] = 'zmyj-baike';
            $tdkData = curl($this->tdkApi, $reqData);
            $tdk['title'] = json_decode($tdkData, true)['data']['t'];
            $tdk['description'] = json_decode($tdkData, true)['data']['d'];
            $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];
        } else {
            $list = Db::name('article')->where('channel', 'ZMYJ')->where('category', $category)->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc, sort desc, id desc')->paginate(10);

            $reqData['code'] = 'zmyj-' . $categoryCode;
            $tdkData = curl($this->tdkApi, $reqData);
            $tdk['title'] = json_decode($tdkData, true)['data']['t'];
            $tdk['description'] = json_decode($tdkData, true)['data']['d'];
            $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];
        }

        $data = [];
        foreach ($list as $key => $val) {
            $data[$key]['id'] = intval($val['id']);
            $data[$key]['category'] = intval($val['category']);
            $data[$key]['cover'] = $val['cover'];
            $data[$key]['title'] = $val['title'];
            $data[$key]['summary'] = $val['summary'];
            $data[$key]['view_count'] = $val['view_count'];
            $data[$key]['tag'] = explode(',', $val['tag']);
            $data[$key]['create_time'] = $val['create_time'];
        }

        $this->assign('list', $data);
        // 获取分页显示
        $page = $list->render();

        $this->assign('tdk', $tdk);

        $this->assign('page', $page);

        $this->assign('category', $categoryCode);
        return $this->fetch();
    }

    /**
     * 百科详情页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function baikeDetail()
    {
        $id = request()->route('id');

        $article = Db::name('article')->where('channel', 'ZMYJ')->where('id', $id)->whereTime('publish_time', '<=',  date('Y-m-d H:i:s', time()))->find();

        // 阅读量统计
        Db::name('article')->where('id', $id)->setInc('view_count');

        // 上一篇
        $prev = Db::name('article')->where('channel', 'ZMYJ')->where('id', '<', $id)->where('category', '<>', 14)->where('enabled', 1)->where('is_trash', 0)->order('id desc')->limit('1')->find();
        // 下一篇
        $next = Db::name('article')->where('channel', 'ZMYJ')->where('id', '>', $id)->where('category', '<>', 14)->where('enabled', 1)->where('is_trash', 0)->order('id asc')->limit('1')->find();

        $category = Db::name('article_category')->where('id', $article['category'])->find();

        $newest = Db::name('article')->where('channel', 'ZMYJ')->where('category', $category['id'])->where('enabled', 1)->where('is_trash', 0)->order('publish_time desc')->limit(5)->select();

        $relevant = Db::name('article')->where('channel', 'ZMYJ')->where('category', $category['id'])->where('enabled', 1)->where('is_trash', 0)->whereTime('publish_time', '<=',  date('Y-m-d H:i:s', time()))->orderRaw('rand()')->limit(5)->select();

        if (!$article) {
            abort(404);
        }

        $this->assign('category', $category);
        $this->assign('article', $article);
        $this->assign('newest', $newest);
        $this->assign('relevant', $relevant);
        $this->assign('prev', $prev);
        $this->assign('next', $next);


        $tdk['title'] = $article['title'];
        $tdk['description'] = $article['summary'];
        $tdk['keywords'] = $article['tag'];

        $this->assign('tdk', $tdk);

        return $this->fetch();
    }

    /**
     * 报名着陆页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function landing()
    {

        $tdk['title'] = '提前算一算,成都装修要花多少钱-致美优家';
        $tdk['description'] = '致美优家，成都首家专注精装房一站式美学整配的优质服务商，100%可还原的整配效果，累计3500+客户的口碑实力，提供 精装房从交房到入住的一站式整配服务，省心，高效。';
        $tdk['keywords'] = '成都精装房装修,精装房美居整配,成都软装公司,成都精装房改造';

        $data = fopen("static/landingData.txt", "r") or die("Unable to open file!");
        $num = fgets($data);
        fclose($data);

        $this->assign('num', $num);

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 微信报名着陆页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function wxlanding()
    {

        $tdk['title'] = '致美优家-您的专属验房服务';
        $tdk['description'] = '致美优家，成都首家专注精装房一站式美学整配的优质服务商，100%可还原的整配效果，累计3500+客户的口碑实力，提供 精装房从交房到入住的一站式整配服务，省心，高效。';
        $tdk['keywords'] = '成都精装房装修,精装房美居整配,成都软装公司,成都精装房改造';

        $data = fopen("static/landingData.txt", "r") or die("Unable to open file!");
        $num = fgets($data);
        fclose($data);

        $this->assign('num', $num);

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 微信公众号回复页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function wxreply()
    {
        $data = Request::only(['code', 'utm_source'], 'get');

        $state = 'wxreply';
        if(isset($data['utm_source'])){
            $state = $data['utm_source'];
        }

        $wechat = new Wechat();
        $userInfo = null;
        if (empty($data['code'])) {
            if(Session::has('wx_user_info')) {
                $userInfo = Session::get('wx_user_info');
                // 判断数据缓存有效期7天
                $cacheTime = Session::get('wx_user_info.cacheTime');
                if (time() - $cacheTime > 3600 * 24 * 7) {
                    Session::clear();
                    if (isset($data['utm_source'])) {
                        $url = 'https://www.bestyoujia.com/wxreply.html?utm_source='.$data['utm_source'];
                    } else {
                        $url = 'https://www.bestyoujia.com/wxreply';
                    }
                    $wechat->oauth($url, $state);
                }
            }else{
                $url = 'https://www.bestyoujia.com/wxreply';
                $wechat->oauth($url, $state);
            }
        } else {
            if(Session::has('wx_user_info')) {
                $userInfo = Session::get('wx_user_info');
                // 判断数据缓存有效期7天
                $cacheTime = Session::get('wx_user_info.cacheTime');
                if (time() - $cacheTime > 3600 * 24 * 7) {
                    Session::clear();
                    if (isset($data['utm_source'])) {
                        $url = 'https://www.bestyoujia.com/wxreply.html?utm_source='.$data['utm_source'];
                    } else {
                        $url = 'https://www.bestyoujia.com/wxreply';
                    }
                    $wechat->oauth($url, $state);
                }
            } else {
                $access_token = $wechat->getAccessToken($data['code']);
                if(!isset($access_token['access_token'])) {
                    $userInfo = null;
                } else {
                    $userInfo = $wechat->getWeChatUserInfo($access_token['access_token'], $access_token['openid']);
                }
            }

            // 未获取到用户信息时重新授权
            if(!$userInfo) {
                if (isset($data['utm_source'])) {
                    $url = 'https://www.bestyoujia.com/wxreply.html?utm_source='.$data['utm_source'];
                } else {
                    $url = 'https://www.bestyoujia.com/wxreply';
                }
                $wechat->oauth($url, $state);
                return false;
            }

            $user = Db::name('wx_user')->where('channel', 'ZMYJ')->where('openid', $userInfo['openid'])->find();

            $userModel = new WxUser();
            if (!$user) {
                // source，1代表公众号，2代表小程序
                $data = ['openid' => $userInfo['openid'], 'nick_name' => $userInfo['nickname'], 'gender' => $userInfo['sex'], 'avatar' => $userInfo['headimgurl'],
                    'country' => $userInfo['country'], 'province' => $userInfo['province'], 'city' => $userInfo['city'], 'channel' => 'ZMYJ', 'source' => 1, 'create_time' => date('Y-m-d H:i:s', time())
                ];
                $userModel->save($data);
            } else {
                $data = ['nick_name' => $userInfo['nickname'], 'gender' => $userInfo['sex'], 'avatar' => $userInfo['headimgurl'],
                    'country' => $userInfo['country'], 'province' => $userInfo['province'], 'city' => $userInfo['city'], 'channel' => 'ZMYJ', 'source' => 1, 'update_time' => date('Y-m-d H:i:s', time())
                ];
                $userModel->save($data, ['openid' => $userInfo['openid']]);
            }
        }

        $tdk['title'] = '0元报价 · 拎包入住';
        $tdk['description'] = '致美优家，成都首家专注精装房一站式美学整配的优质服务商，100%可还原的整配效果，累计3500+客户的口碑实力，提供 精装房从交房到入住的一站式整配服务，省心，高效。';
        $tdk['keywords'] = '成都精装房装修,精装房美居整配,成都软装公司,成都精装房改造';

        $code = 'wxreply';
        $channel = 'ZMYJ';
        $count = Db::name('count')->where('channel','like','%' . $channel . '%')->where('code', $code)->find();

        $this->assign('tdk', $tdk);
        $this->assign('num', $count['count']);
        $this->assign('userInfo', $userInfo);
        return $this->fetch();
    }

    /**
     * 微信品牌页
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function wxBrand()
    {
        $reqData['code'] = 'zmyj-about';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 添加设计师微信
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function wxSubscribe()
    {
        $reqData['code'] = 'zmyj-home';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 泛微全屋定制
     * @return mixed
     */
    public function wxCustomized()
    {
        $reqData['code'] = 'zmyj-about';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 公众号精装房案例报名页
     * @return mixed
     */
    public function wxCase()
    {
        $reqData['code'] = 'zmyj-about';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = '致美优家-精装房实景案例0元获取';
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 公众号精装房案例报名页
     * @return mixed
     */
    public function wxcase20211125()
    {
        $reqData['code'] = 'zmyj-about';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = '信息流朋友圈-案例报价';
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * 微信报名着陆页202106
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function wxlanding202106()
    {

        $tdk['title'] = '致美优家-专注精装房美学软装整配服务';
        $tdk['description'] = '致美优家，成都首家专注精装房一站式美学整配的优质服务商，100%可还原的整配效果，累计3500+客户的口碑实力，提供 精装房从交房到入住的一站式整配服务，省心，高效。';
        $tdk['keywords'] = '成都精装房装修,精装房美居整配,成都软装公司,成都精装房改造';

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }

    /**
     * VR浏览
     * @return string
     */
    public function vr()
    {
        $reqData['code'] = 'zmyj-vr';
        $tdkData = curl($this->tdkApi, $reqData);
        $tdk['title'] = json_decode($tdkData, true)['data']['t'];
        $tdk['description'] = json_decode($tdkData, true)['data']['d'];
        $tdk['keywords'] = json_decode($tdkData, true)['data']['k'];

        $this->assign('tdk', $tdk);
        return $this->fetch();
    }
}
